import axios from '@/utils/request'

/**
 * 获取员工列表
 * @param {*} params {page:页码，size:条数}
 * @returns
 */
export const getEmloyeesListAPI = (params) => {
  return axios({
    url: '/sys/user',
    params
  })
}
// 新增员工
/**
 *
 * @param {*} data 员工的信息对象(7对key/value)
 * @returns
 */
export const addEmloyeesAPI = (data) => {
  return axios({
    url: '/sys/user',
    method: 'POST',
    data
  })
}
// 删除员工
/**
 * @description: 删除员工
 * @param {*} id 员工id
 * @return {*}
 */
export const delEmployeeAPI = (id) => {
  return axios({
    method: 'DELETE',
    url: `/sys/user/${id}`
  })
}
/** 批量导入员工
 * @description: 导入excel
 * @param {*} data
 * @return {*}
 */
export const importEmployeeAPI = (data) => {
  return axios({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}
/** 保存员工基本信息
 *
 * @param {*} empObj  员工数据对象
 * @returns
 */
export const saveEmployeeAPI = (empObj) => {
  return axios({
    url: `/sys/user/${empObj.id}`,
    method: 'PUT',
    data: empObj
  })
}
/**
 * @description: 为员工分配角色
 * @param {*} data { id:当前用户id, roleIds:选中的角色id组成的数组 }
 * @return {*}
 */
export const assignRolesAPI = (data) => {
  return axios({
    url: '/sys/user/assignRoles',
    data,
    method: 'put'
  })
}
